package com.cloud.lawcase.api.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.cloud.lawcase.api.entity.TcLawRelCauseLawItem;
import com.cloud.lawcase.common.utils.BaseMapperHelper;

public interface TcLawRelCauseLawItemMapper extends BaseMapperHelper<TcLawRelCauseLawItem> {

	@Delete("delete from tc_law_rel_cause_law_item where law_id in (select law_id from tc_dic_law where group_id = #{groupId})")
	void deleteByGroupId(@Param("groupId") Long groupId);

	@Select("select t1.cause_id, t1.item_id, t1.item_type_id, t2.item_type_name from tc_law_rel_cause_law_item t1 left join tc_dic_law_item_type t2 on t1.item_type_id = t2.item_type_id where t1.law_id = #{lawId}")
	@Results({ @Result(column = "cause_id", property = "causeId", javaType = Long.class),
			@Result(column = "item_id", property = "itemId", javaType = Long.class),
			@Result(column = "item_type_id", property = "itemTypeId", javaType = Integer.class),
			@Result(column = "item_type_name", property = "itemTypeName", javaType = String.class) })
	List<TcLawRelCauseLawItem> listRelCauseItemByLawId(long lawId);

	@Delete("delete from tc_law_rel_cause_law_item where cause_id = #{causeId}")
	void deleteByCauseId(@Param("causeId") long causeId);
}